package cn.raven.controller;

import cn.raven.entity.Product;
import cn.raven.entity.Store;
import cn.raven.feign.StoreFeignClient;
import cn.raven.service.IProductService;
import cn.raven.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;
    @Autowired
    private StoreFeignClient feignClient;
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Product product){
        try {
            return productService.add(product);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("失败").setSuccess(false);
        }
    }

    @GetMapping("/no")
    public AjaxResult no(@RequestBody  Store store){
        return feignClient.add(store);
    }
}
